<?php defined('IN_IA') or exit('Access Denied');?><!DOCTYPE html>
<html lang="en">
<head>
    <?php (!empty($this) && $this instanceof WeModuleSite || 1) ? (include $this->template('common/edithead', TEMPLATE_INCLUDEPATH)) : (include template('common/edithead', TEMPLATE_INCLUDEPATH));?>
    <!--系统 -->
    <!--这个放在最后一切平白安全-->
    <script type="text/javascript" src="./resource/js/require.js?v=20170915"></script>
    <script type="text/javascript">
        //编辑器里使用
        var urobj=[];
    </script>
</head>
<body class="nav-md" style="min-width: 800px">
<div>
    <div class="container xc_edit_from" >
        <div class="main_container" style="overflow-x: hidden;min-height: calc(100vh - 20px);background-color: white;width: 100%;">
            <div class="col-md-12 col-xs-12">
                <div class="x_panel">
                    <ul class="we7-page-tab">
                        <li >
                            <a  href="<?php  echo $this->createWebUrl($do, array('op'=>'list','xtitleb'=>urlencode($xtitleb),'xtitlea'=>urlencode($xtitlea),'new'=>1));?>">
                                <?php  echo $xtitleb;?>- <?php  echo $xtitlea;?>列表  </a></li>
                        <li><a a href="<?php  echo $this->createWebUrl($do, array('op'=>'edit','xtitleb'=>urlencode($xtitleb),'xtitlea'=>urlencode($xtitlea),'new'=>1));?>"><?php  echo $xtitleb;?>- <?php  echo $xtitlea;?>增加</a></li>
                    </ul>
                    <div class="x_content">
                        <br/>
                        <form id="sign-form" class="form-horizontal" role="form" method="post" name="submit">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">课程</label>
                                <div class="col-sm-8">
                                    <select  class="form-control js-select2" name="pid" data-select="<?php  echo $list['pid'];?>">
                                        <option value="">请选择课程</option>
                                        <?php  if(is_array($class)) { foreach($class as $index => $item) { ?>
                                        <option data-fee="<?php  echo $vo['fee'];?>" value="<?php  echo $item['id'];?>" <?php  if($item['id']==$list['pid']) { ?>selected<?php  } ?> ><?php  echo $item['name'];?></option>
                                        <?php  } } ?>
                                    </select>
                                    <input type="hidden" name="id" value="<?php  echo $list['id'];?>">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">标识</label>
                                <div class="col-sm-8">
                                    <input type="text" class="form-control"  name="mark" value="<?php  echo $list['mark'];?>">
                                    <span class="help-block">免费的课程可选择公开课或新开课，收费课程只能选新开课</span>
                                </div>
                            </div>
                            <div class="form-group">
                                <label  class="col-sm-2 control-label">类型</label>
                                <div class="col-sm-8">
                                    <label class="radio inline">
                                        <input type="radio" class="ui-radio" name="type" id="type1" value="1" <?php  if($list['type']==1) { ?>checked<?php  } ?>>公开课
                                    </label>
                                    <label class="radio inline">
                                        <input type="radio" class="ui-radio" name="type" id="type2" value="2" <?php  if($list['type']==2) { ?>checked<?php  } ?>>新开课
                                    </label>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">开课时间</label>
                                <div class="col-sm-8">
                                    <?php  echo tpl_form_field_date('start_time',$list['start_time'],true);?>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">报名/预约截止时间</label>
                                <div class="col-sm-8">
                                    <?php  echo tpl_form_field_date('end_time',$list['end_time'],true);?>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">开课最少人数</label>
                                <div class="col-sm-8">
                                    <input type="text" class="form-control"  name="least_member" value="<?php  echo $list['least_member'];?>">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">开课最多人数</label>
                                <div class="col-sm-8">
                                    <input type="text" class="form-control"  name="more_member" value="<?php  echo $list['more_member'];?>">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">状态</label>
                                <div class="col-sm-8">
                                    <input type="checkbox" class="js-switch" value="1" name="status"
                                           data-value="<?php  echo $list['status'];?>" data-field="status">
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-offset-2 col-sm-10">
                                    <input type="button" name="submit" class="btn btn-default" value="提交">
                                    <a type="button" class="btn btn-default"  href="<?php  echo $this->createWebUrl($do, array('op'=>'list','xtitleb'=> urlencode($xtitleb),'xtitlea'=>urlencode($xtitlea),'new'=>1));?>" >返回</a>
                                    <input id="res" name="res" type="reset" style="display:none;" />
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>

</div>
<?php (!empty($this) && $this instanceof WeModuleSite || 1) ? (include $this->template('common/editfoot', TEMPLATE_INCLUDEPATH)) : (include template('common/editfoot', TEMPLATE_INCLUDEPATH));?>
<script>
    function dd(){
        var index=$('#pid option:selected').attr("data-fee");
        if(index==1){
            $("#type2").prop("checked",true);
        }
    }
    $(function(){
        $("#pid").on('change',function(){
            dd();
        });
        $("input[name='type']").change(function(){
            dd();
        });
        $("input[name='submit']").click(function(){
            var data=$(".form-horizontal").serialize();
            $.ajax({
                type:"post",
                url:"<?php  echo url('site/entry/'.$_GPC['do'],array('m'=>$_GPC['m'],'op'=>'savemodel','version_id'=>$_GPC['version_id']));?>",
                data:data,
                dataType:'json',
                success:function(res){
                    if(res.status==1){
                        if($("input[name='id']").val()==""){
                            $("input[name='res']").click();
                            $("body").find(".img-responsive.img-thumbnail").attr("src","");
                        }
                        swal('操作成功!', '操作成功!', 'success');
                    }else{
                        swal('操作失败!', '操作失败!', 'error');
                    }
                }
            })
        });
    })
</script>
</body>
</html>